// JavaScript Document

function check_right(u,r,m,f1,f2) {
	$.ajax({
		url:'modules/quyen/s.php',
		type:'POST',
		dataType:'xml',
		data:"un="+u+"&mamod="+m,
		success:function(xml){
			var xem=false;
			var them=false;
			var sua=false;
			var xoa=false;
			
			var k=$(xml).find('row');
			if(k[0].childNodes[2].text)
			{
				xem=(k[0].childNodes[2].text=='C');
				them=(k[0].childNodes[3].text=='C');
				sua=(k[0].childNodes[4].text=='C');
				xoa=(k[0].childNodes[5].text=='C');
			}
			else
			{
				xem=(k[0].childNodes[2].textContent=='C');
				them=(k[0].childNodes[3].textContent=='C');
				sua=(k[0].childNodes[4].textContent=='C');
				xoa=(k[0].childNodes[5].textContent=='C');
			}
			if(r=="select")
			{
				if(xem) {if(f1!==null) f1();} else {if(f2!==null) f2();}
			}
			else if(r=="insert")
			{
				if(them) {if(f1!==null) f1();} else {if(f2!==null) f2();}
			}
			else if(r=="update")
			{
				if(sua) {if(f1!==null) f1();} else {if(f2!==null) f2();}
			}
			else if(r=="delete")
			{
				if(xoa) {if(f1!==null) f1();} else {if(f2!==null) f2();}
			}
		}
	}); // ajax
};// function init
